<?php

class personal_model extends FlexiGrid_Model {

    function __construct()
    {
        parent::__construct();
        
    }
    
    function delete($ID){
        $this->db->set('Delete', 'NOW()', FALSE);
        $where=array("ID"=>$ID);
        $this->db->where($where);
        $this->db->update('tbl_tour'); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    function retore($ID){
        $this->db->set('Delete', 'NULL', FALSE);
        $where=array("ID"=>$ID);
        $this->db->where($where);
        $this->db->update('tbl_tour'); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    
    function FlexiGridData(){
        $configs["strQuery"]="
            SELECT SQL_CALC_FOUND_ROWS `tbl_personal`.*
            FROM `tbl_personal`
            ";
        $configs["strWhere"]="
            WHERE true
            ";
        
        if( $_SESSION["ADP"][CCTRL]["display"]==0){
            $configs["strWhere"].=" AND `tbl_personal`.`Delete` IS NULL";
        }elseif( $_SESSION["ADP"][CCTRL]["display"]==-1){
            $configs["strWhere"].=" AND `tbl_personal`.`Delete` IS NOT NULL";
        }
        $configs["strOrderBy"]=" ORDER BY `Insert` DESC";
        $configs["fields"]=array(
            "FullName"=>"Name"
            );
        $configs["filterfields"]=array(
            "Name","Email","Phone","Address"
        );
        $this->init($configs);
        return $this->Binding();
    }
    function FlexiGridData_Commercial(){
        $configs["strQuery"]="
            SELECT SQL_CALC_FOUND_ROWS `tbl_commercial`.*
            FROM `tbl_commercial`
            ";
        $configs["strWhere"]="
            WHERE true
            ";
        
        if( $_SESSION["ADP"][CCTRL]["display"]==0){
            $configs["strWhere"].=" AND `Delete` IS NULL";
        }elseif( $_SESSION["ADP"][CCTRL]["display"]==-1){
            $configs["strWhere"].=" AND `Delete` IS NOT NULL";
        }
        $configs["strOrderBy"]=" ORDER BY `Insert` DESC";
        $configs["fields"]=array(
            
            );
        $configs["filterfields"]=array(
            "CompanyName","Email","Phone","Address"
        );
        $this->init($configs);
        return $this->Binding();
    }
}
?>
